package com.dtkavin.sparkstreaming

import org.apache.spark.SparkConf
import org.apache.spark.streaming.{Seconds, Duration, Milliseconds, StreamingContext}

/**
  * Created by IntelliJ IDEA.
  * Programmer : John Zn
  * Date : 2016/4/21 0021
  * Time : 23:20
  * Discribtion : 滑动窗口，以时间为基准，间隔性获取窗口大小的rdd信息
  */
class WindowSlideStreaming {

}

object WindowSlideStreaming {
  def main(args: Array[String]) {
    SelfLogging.getSelfLoggingLevel("WARN")
    val conf = new SparkConf().setAppName("WindowSliedStreaming").setMaster("local[3]")
    val ssc = new StreamingContext(conf, Milliseconds(5000))
    //window（weight,slide-step）
    val res = ssc.socketTextStream("log01", 9999)
      .window(Seconds(15), Seconds(20))//20秒取一个窗口，窗口大小为15s，目前配置为3个rdd
    res.print()

    ssc.start()
    ssc.awaitTermination()
  }
}
